package com.example.controller;


import com.example.entity.Category;
import com.example.result.Result;
import com.example.service.ICategoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/category")
@Slf4j
@RequiredArgsConstructor
public class CategoryController {

    private final ICategoryService categoryService;

    /*
    * 添加分类
    * @Param category
    * @Return
    * */
    @PostMapping("/add")
    public Result addCategory(@RequestBody Category category){
        categoryService.addCategory(category);
        return Result.success();
    }

    /*
    * 查询分类
    * @Param category
    * @Return
    * */
    @GetMapping
    public Result QueryCategory(){
        return Result.success(categoryService.list());
    }
}
